<?php

/**
 * Factura filter form base class.
 *
 * @package    aeropostal
 * @subpackage filter
 * @author     Your name here
 */
abstract class BaseFacturaFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'numControl' => new sfWidgetFormFilterInput(),
      'fecha'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'fechaTrans' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'numTrans'   => new sfWidgetFormFilterInput(),
      'moneda'     => new sfWidgetFormPropelChoice(array('model' => 'Moneda', 'add_empty' => true)),
      'uMedida'    => new sfWidgetFormPropelChoice(array('model' => 'Unidmedida', 'add_empty' => true)),
      'estacion'   => new sfWidgetFormPropelChoice(array('model' => 'Estacion', 'add_empty' => true)),
      'empresa'    => new sfWidgetFormPropelChoice(array('model' => 'Compania', 'add_empty' => true)),
      'transmitir' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'reclamo'    => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'cantTotal'  => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'total'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'estatus'    => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'numControl' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'fecha'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'fechaTrans' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'numTrans'   => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'moneda'     => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Moneda', 'column' => 'id')),
      'uMedida'    => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Unidmedida', 'column' => 'simbolo')),
      'estacion'   => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Estacion', 'column' => 'codigo')),
      'empresa'    => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Compania', 'column' => 'id')),
      'transmitir' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'reclamo'    => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'cantTotal'  => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'total'      => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'estatus'    => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('factura_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Factura';
  }

  public function getFields()
  {
    return array(
      'numero'     => 'Text',
      'numControl' => 'Number',
      'fecha'      => 'Date',
      'proveedor'  => 'ForeignKey',
      'fechaTrans' => 'Date',
      'numTrans'   => 'Number',
      'moneda'     => 'ForeignKey',
      'uMedida'    => 'ForeignKey',
      'estacion'   => 'ForeignKey',
      'empresa'    => 'ForeignKey',
      'transmitir' => 'Boolean',
      'reclamo'    => 'Boolean',
      'cantTotal'  => 'Number',
      'total'      => 'Number',
      'estatus'    => 'Text',
    );
  }
}
